﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;

namespace LibraryManagement
{
    public partial class AdminDashboard : Form
    {
        private Form parentForm;
        //private string adminId;
        public AdminDashboard(Form parent)
        {
            InitializeComponent();
            parentForm = parent;
            //this.adminId = adminId;
            LoadBooks();
        }
        private void LoadBooks()
        {
            string query = "SELECT BookID, Title, Author, ISBN FROM Books";
            DataTable dt = DatabaseHelper.ExecuteQuery(query);
            //dgvBooks.DataSource = dt;
        }

        //private void btnAddBookModule_Click(object sender, EventArgs e)
        //{
        //    AddBookForm addBookForm = new AddBookForm(this);
        //    addBookForm.Show();
        //    this.Hide();
        //}

        //private void btnViewBooksModule_Click(object sender, EventArgs e)
        //{
        //    BookListForm bookListForm = new BookListForm(this);
        //    bookListForm.Show();
        //    this.Hide();
        //}

        //private void btnViewLogsModule_Click(object sender, EventArgs e)
        //{
        //    OperationLogsForm logsForm = new OperationLogsForm(this);
        //    logsForm.Show();
        //    this.Hide();
        //}

        //private void btnBack_Click(object sender, EventArgs e)
        //{
        //    parentForm.Show();
        //    this.Close();
        //}

        private void btnAddBookModule_Click_1(object sender, EventArgs e)
        {
            AddBookForm addBookForm = new AddBookForm(this);
            addBookForm.Show();
            this.Hide();
        }

        private void btnViewBooksModule_Click_1(object sender, EventArgs e)
        {
            BookListForm bookListForm = new BookListForm(this);
            bookListForm.Show();
            this.Hide();
        }

        private void btnViewLogsModule_Click_1(object sender, EventArgs e)
        {
            OperationLogsForm logsForm = new OperationLogsForm(this);
            logsForm.Show();
            this.Hide();
        }

        private void btnDeleteBook_Click_1(object sender, EventArgs e)
        {
            DeleteBookForm deleteBookForm = new DeleteBookForm(this);
            deleteBookForm.Show();
            this.Hide();
        }


        private void btnBack_Click_1(object sender, EventArgs e)
        {
            parentForm.Show();
            this.Close();
        }

        private void AdminDashboard_Load(object sender, EventArgs e)
        {

        }

        private void btnEditBook_Click(object sender, EventArgs e)
        {
            EditBookForm editBookForm = new EditBookForm(this);
            editBookForm.Show();
            this.Hide();
        }

        //private void btnDeleteBook_Click(object sender, EventArgs e)
        //{
        //    //DeleteBookForm deleteForm = new DeleteBookForm(this);
        //    //deleteForm.Show();
        //    //this.Hide();
        //    BookListForm bookListForm = new BookListForm(this);
        //    int? bookId = bookListForm.GetSelectedBookId();

        //    if (bookId.HasValue)
        //    {
        //        DeleteBookForm deleteForm = new DeleteBookForm(this);
        //        deleteForm.Show();
        //    }
        //    else
        //    {
        //        MessageBox.Show("请选择一本图书进行删除！");
        //    }
        //}

        //private void btnEditBook_Click(object sender, EventArgs e)
        //{
        //    if (dgvBooks.SelectedRows.Count > 0)
        //    {
        //        int bookId = (int)dgvBooks.SelectedRows[0].Cells["BookID"].Value;
        //        EditBookForm editForm = new EditBookForm(bookId);
        //        editForm.Show();
        //        this.Hide();
        //    }
        //    else
        //    {
        //        MessageBox.Show("请选择一本图书进行修改！");
        //    }
        //}
    }
}
